<?php
namespace Amis\dataviewer;

use Amis\Basics\AmisBasics;

class GridNav extends AmisBasics
{
    public string $type = 'grid-nav';

    public function className(string $className)
    {
        $this->className = $className;
        return $this;
    }

    /**
     * 列表项 css 类名
     * @param string $itemClassName
     * @return $this
     */
    public function itemClassName(string $itemClassName)
    {
        $this->itemClassName = $itemClassName;
        return $this;
    }

    /**
     * 图片数组
     * @param string|array $value
     * @return $this
     */
    public function value($value)
    {
        $this->value = $value;
        return $this;
    }

    /**
     * 数据源
     * @param string $source
     * @return $this
     */
    public function source(string $source)
    {
        $this->source = $source;
        return $this;
    }

    /**
     * 是否将列表项固定为正方形
     * @param bool $square
     * @return $this
     */
    public function square(bool $square)
    {
        $this->square = $square;
        return $this;
    }

    /**
     * 是否将列表项内容居中显示
     * @param bool $center
     * @return $this
     */
    public function center(bool $center = true)
    {
        $this->center = $center;
        return $this;
    }

    /**
     * 是否显示列表项边框
     * @param bool $border
     * @return $this
     */
    public function border(bool $border = true)
    {
        $this->border = $border;
        return $this;
    }

    /**
     * 列表项之间的间距，默认单位为px
     * @param int $gutter
     * @return $this
     */
    public function gutter(int $gutter)
    {
        $this->gutter = $gutter;
        return $this;
    }

    /**
     * 是否调换图标和文本的位置
     * @param bool $reverse
     * @return $this
     */
    public function reverse(bool $reverse)
    {
        $this->reverse = $reverse;
        return $this;
    }

    /**
     * 图标宽度占比，单位%
     * @param int $iconRatio
     * @return $this
     */
    public function iconRatio(int $iconRatio = 60)
    {
        $this->iconRatio = $iconRatio;
        return $this;
    }

    /**
     * 列表项内容排列的方向，可选值为 horizontal 、vertical
     * @param string $direction
     * @return $this
     */
    public function direction(string $direction = 'vertical')
    {
        if (in_array($direction, ['horizontal', 'vertical']))
            $this->direction = $direction;
        return $this;
    }

    /**
     * 列数
     * @param int $columnNum
     * @return $this
     */
    public function columnNum(int $columnNum = 4)
    {
        $this->columnNum = $columnNum;
        return $this;
    }

    /**
     * @param \Amis\dataviewer\GridNavOptions $options
     * @return \Amis\dataviewer\GridNavOptions
     */
    public function options(GridNavOptions $options)
    {
        return $this->options = $options;
    }
}